<template>
  <div class="order">
    <div class="headerhh">
      <div @click="goBack" style="float: left">
        <a-icon type="left" class="icon" />
        <a class="h3">详情</a>
      </div>
    </div>
    <div class="infomain">
      <video :src=this.$route.query.id controls="controls" id='upvideo' poster="" ref='myvideo'></video>
      <!-- <video id="playVideos" controls poster='' preload x5-video-player-type="h5">
        <source :src="this.$route.query.id" id="playVideosss" ref="video" type="video/mp4" />
      </video> -->
    </div>
  </div>
</template>

<script>
export default {
  name: 'headerhh',
  data () {
    return {
      dataimg: ''
    }
  },
  mounted () {
    // console.log(this.$route.query.id)
    // this.$nextTick(() => {
    //   // this._listData(this.currentPage, this.pageSize)
    //   // this.test()
    //   setTimeout(() => {
    //     this.captureImage()
    //   }, 1000)
    // })
    this.findvideocover()
  },
  methods: {
    findvideocover () {
      // let _this = this
      this.$nextTick(() => {
        let video = document.getElementById('upvideo')
        let source = document.createElement('source')
        // source.src = require("../../assets/5b086751dbb7af1ea8fa8d05e66fe5c3.mp4");this.formLabelAlign.video
        source.src = this.$route.query.id
        source.type = 'video/mp4'
        video.appendChild(source)
        video.addEventListener('loadeddata', function () {
          var canvas = document.createElement('canvas')
          var scale = 0.8
          canvas.width = video.videoWidth * scale
          canvas.height = video.videoHeight * scale
          canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.width)
          var img = document.createElement('img')
          img.src = canvas.toDataURL('image/png')
          // console.log(img.src)
          // video.poster = img.src
          // console.log(video.poster)
          // _this.Videoframehandle(imgsrc.split(',')[1])
        })
      })
    },
    // captureImage () {
    //   var video = document.getElementById('upvideo')
    //   var scale = 0.8
    //   var canvas = document.createElement('canvas')
    //   canvas.width = video.videoWidth * scale
    //   canvas.height = video.videoHeight * scale
    //   canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height)
    //   var img = document.createElement('img')
    //   img.src = canvas.toDataURL()
    //   this.src = img.src
    // },
    goBack () {
      this.$router.push({
        path: '/healthInfo',
        query: { dpId: this.$route.query.dpId }
      })
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '../../../static/css/color.styl';

.order {
  position: relative;
  background-color: $color-grayc;
  height: 100%;
  overflow: hidden;
}

.headerhh {
  height: 0.98rem;
  background-color: $color-main;
  text-align: justify;
  line-height: 0.98rem;
  padding-left: 0.3rem;
  color: $color-white;
  margin-bottom: 0.3rem;

  .icon {
    font-size: 0.36rem;
    color: $color-white;
    vertical-align: -0.07rem;
  }

  .h3 {
    display: inline-block;
    font-size: 0.36rem;
    color: $color-white;
  }
}

.anticon {
  font-size: 0.26rem;
  vertical-align: -0.23em;
}

.infomain {
  position: relative;
  height: 10.4rem;
  box-shadow: 3px 3.464px 12px 0px rgba(127, 135, 143, 0.2);
  // padding: 0.3rem;
  overflow-y: auto;
  margin-left: 0.2rem;

  video {
    width: 18.8rem;
    height: 9.8rem;
  }
}
</style>
